//
//  PlayScene.h
//  test
//
//  Created by x86mac on 15-8-12.
//
//

#ifndef __test__PlayLayer__
#define __test__PlayLayer__

#include "cocos2d.h"
#include "Animal.h"
#include "GameData.h"

USING_NS_CC;
typedef std::pair<int, int> Index;
class PlayLayer 
:public cocos2d::Layer
{
public:
    PlayLayer();
    static cocos2d::Scene * createScene();
    virtual bool init();
    CREATE_FUNC(PlayLayer);
    
    void initMatrix();
    void createAndDropAnimal();
    Point getPositionOfAnimal(int row, int col);
    Index getAnimalIndexForTouched(Point *point);
    void swapTwoAnimal();
    void removeAnimal();
    void removeAndCreate();
    void down();
    void setIsTouchMoved();
    virtual bool onTouchBegan(Touch *touch, Event *unused_event); 
    virtual void onTouchEnded(Touch *touch, Event *unused_event); 
    Animal* animalMatrix[GameData::HEIGHT_NUM][GameData::WIDTH_NUM];
private:
    float mMatrixLeftBottomX;
    float mMatrixLeftBottomY;
    Index selAnimalIndex;
    Index swapAnimalIndex;
    bool isTouchMoved;
};




#endif /* defined(__test__PlayScene__) */
